package utils;

public class PhoneUtils {

    /**
     * 隐藏手机号的中间四位
     * @param phone
     * @return
     */
    public static final String hideCentralNum(String phone) {
        if (phone == null) {
            return "Invalid phone number";
        } else {
            int len = phone.length();
            if (len == 11) {
                StringBuilder builder = new StringBuilder(phone.substring(0, 3))
                        .append("XXXX").append(phone.substring(7));
                return builder.toString();
            } else {
                return "Invalid phone number";
            }
        }
    }
}
